package com20230214.xiti;

import java.util.Arrays;

public class Demo04 {
    public static void main(String[] args) {

        int[] arr = {12,43,45,76,78,98,23,21,34,56};
        int i = 2;
        int []arr1 = panDuan(arr,i);
        System.out.println(Arrays.toString(arr1));

    }
    static int[] panDuan(int[] arr,int a){

        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] % a == 0){
                count++;

            }

        }


        int[] arr1 = new int[count];

        for (int i = 0,start =0; i < arr.length; i++) {
            if(arr[i] % a == 0){
                arr1[start++] = arr[i];
            }


        }

       return arr1;

    }
}
